import { Alert, Platform } from 'react-native';

export interface ImageInfo {
    path: string;
    timestamp: string;
    faceCount: number;
    metadata?: any;
}

class ImageProcessor {
    /**
     * 获取图片信息
     * @param imagePath 图片路径
     * @returns Promise<ImageInfo> 图片信息
     */
    static async getImageInfo(imagePath: string, faceCount: number = 0): Promise<ImageInfo> {
        return {
            path: imagePath,
            timestamp: new Date().toISOString(),
            faceCount: faceCount,
            metadata: {
                source: 'face_detection',
                platform: Platform.OS,
                version: '1.0.0'
            }
        };
    }

    /**
     * 验证图片路径是否有效
     * @param imagePath 图片路径
     * @returns boolean 是否有效
     */
    static isValidImagePath(imagePath: string): boolean {
        return Boolean(imagePath && imagePath.length > 0 && imagePath.startsWith('file://'));
    }

    /**
     * 获取图片文件名
     * @param imagePath 图片路径
     * @returns string 文件名
     */
    static getFileName(imagePath: string): string {
        const parts = imagePath.split('/');
        return parts[parts.length - 1] || 'unknown.jpg';
    }

    /**
     * 显示图片信息
     * @param imageInfo 图片信息
     */
    static showImageInfo(imageInfo: ImageInfo): void {
        Alert.alert(
            '图片信息',
            `路径: ${imageInfo.path}\n时间: ${imageInfo.timestamp}\n人脸数量: ${imageInfo.faceCount}`,
            [{ text: '确定' }]
        );
    }
}

export default ImageProcessor; 